<style lang="less" scoped>
    .highsearch {
        width: 100%;
        height: auto;
        .searchbut{
            display: flex;
            justify-content: flex-end;
            margin-bottom: 10px;
        }
    }
</style>
<template>
    <div class="highsearch">
        <Form :model="formMode" :label-width="80" ref="highSearchForm">
            <Row>
                <Col span="6" v-for="(item, index) in formForm" :key="index" style="height: 38px">
                    <FormItem :label="item.label" :prop="item.key">
                        <Input v-model="formMode[item.key]" :placeholder="item.placeholder"></Input>
                    </FormItem>
                </Col>
            </Row>
            <div class="searchbut">
                <Button type="primary" style="margin-right: 10px" @click="highSearchClick">搜索</Button>
                <Button type="ghost" @click="reset('highSearchForm')">清空</Button>
            </div>
        </Form>
    </div>
</template>
<script>
    export default {
        name: 'highsearch',
        props: {
            formItem: {
                type: Array,
                default: () => {
                    return []
                }
            },
            searchForm: {
                type: Object,
                default: () => {
                    return {}
                }
            }
        },
        data () {
            return {
                formMode: JSON.parse(JSON.stringify(this.searchForm)),
                formForm: JSON.parse(JSON.stringify(this.formItem))
            }
        },
        computed: {
        },
        methods: {
            reset (name) {
                this.$refs[name].resetFields()
                this.$emit('reset')
            },
            highSearchClick () {
                let data = {}
                for (let item in this.formMode) {
                    if (this.formMode[item] != '') {
                        data[item] = this.formMode[item]
                    }
                }
                console.log(data)
                this.$emit('highSearch', data)
            }
        },
        components: {
        },
        mounted: function () {
        }
    };
</script>
